<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "user".
 *
 * @property int $user_id
 * @property string $user_number
 * @property string $user_name
 * @property string $user_pwd
 */
class Users extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_number'], 'string', 'max' => 11],
            [['user_name'], 'string', 'max' => 30],
            [['user_pwd'], 'string', 'max' => 32],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'user_id' => 'User ID',
            'user_number' => 'User Number',
            'user_name' => 'User Name',
            'user_pwd' => 'User Pwd',
        ];
    }
    //添加数据方法
    public function addData()
    {
        return $this->save();
    }
    //登录 查询方法
    public function findData($data)
    {
        return $this->find()
        ->where(['user_name'=>$data['user_name'],'user_pwd'=>$data['user_pwd']])
        ->asArray()
        ->one();

    }
}
